package servlet;

import dao.GoodsDao;
import dao.UserDao;
import model.Goods;
import model.User;
import service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/DisableGoodsServletUser.do")
public class DisableGoodsServletUser extends HttpServlet {




    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String idParam = req.getParameter("id");
        if (idParam == null || idParam.isEmpty()) {
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "User ID is required");
            return;
        }


        int Goods_Id = Integer.parseInt(idParam);
        GoodsDao goodsDao = new GoodsDao();
        boolean success2 = goodsDao.delete(Goods_Id);
        if(success2){
            resp.sendRedirect("background1/user/goodsManager.jsp");
        }else {
            resp.sendRedirect("home/404.html");
        }

    }



}
